from varible import cur, TABLE_NAME, connection

cur.execute("""
    delete
    from 51job_table
    where right(providesalary_text,3) ="" or right(providesalary_text,3)="上/年" or right(providesalary_text,3)="下/年"
    or right(providesalary_text,3)="上/月" or right(providesalary_text,3)="下/月";
""")

cur.execute("""select providesalary_text from 51job_table;""")
providesalary_text = cur.fetchall()
for i in providesalary_text:
    tmp = 0
    if i[0][-3:] == "万/月":
        tmp = float(i[0][:-3].split("-")[0]) * 10
    if i[0][-3:] == "万/年":
        tmp = float(i[0][:-3].split("-")[0]) * 10 / 12
    if i[0][-3:] == "元/天":
        tmp = float(i[0][:-3].split("-")[0]) * 30 / 1000
    if i[0][-4:] == "元/小时":
        tmp = float(i[0][:-4].split("-")[0]) * 24 * 30 / 1000
    if i[0][-3:] == "千/月":
        tmp = float(i[0][:-4].split("-")[0])
    cur.execute("""update {} set providesalary_text= '{}' where providesalary_text='{}'""".format(TABLE_NAME, tmp, i[0]))
    connection.commit()
    print(i[0])
